package com.supcalls;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.DigestUtil;
import java.io.File;

public class MD5Example {
    public static void main(String[] args) {
        // 计算字符串的 MD5
        String text = "Hello, Hutool!";
        String md5Secure = SecureUtil.md5(text);
        String md5Digest = DigestUtil.md5Hex(text);

        System.out.println("MD5 using SecureUtil: " + md5Secure);
        System.out.println("MD5 using DigestUtil: " + md5Digest);

        // 计算文件的 MD5
        File file = new File("test.txt"); // 请确保 test.txt 存在
        if (file.exists()) {
            String md5File = DigestUtil.md5Hex(file);
            System.out.println("MD5 of file (test.txt): " + md5File);
        } else {
            System.out.println("File test.txt not found.");
        }
    }
}

